<script setup lang="ts">
import { useTabBarStore } from '@/stores';
import { useRoute } from 'vue-router';
const tabBarStore = useTabBarStore();
const cacheList = computed(() => tabBarStore.getCacheList);
/** - <router-view> 上需要设置一个key，避免组件复用 */
const route = useRoute();
const routerKey = computed(() => {
  return route.path + Math.random();
});
/*** - end */
</script>

<template>
  <router-view v-slot="{ Component, route }" :key="routerKey">
    <transition name="fade" mode="out-in" appear>
      <component :is="Component" v-if="route.meta.ignoreCache" :key="route.fullPath" />
      <keep-alive v-else :include="cacheList">
        <component :is="Component" :key="route.fullPath" />
      </keep-alive>
    </transition>
  </router-view>
</template>
